class StockItem {
  final String id;
  final String name;
  final String category;
  final String unit;
  final double price;
  final int quantity;
  final String supplier;
  final DateTime entryDate;
  final String notes;

  StockItem({
    required this.id,
    required this.name,
    required this.category,
    required this.unit,
    required this.price,
    required this.quantity,
    required this.supplier,
    required this.entryDate,
    required this.notes,
  });

  factory StockItem.fromJson(Map<String, dynamic> json) {
    return StockItem(
      id: json['id'] as String,
      name: json['name'] as String,
      category: json['category'] as String,
      unit: json['unit'] as String,
      price: (json['price'] as num).toDouble(),
      quantity: json['quantity'] as int,
      supplier: json['supplier'] as String,
      entryDate: DateTime.parse(json['entryDate'] as String),
      notes: json['notes'] as String,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'name': name,
      'category': category,
      'unit': unit,
      'price': price,
      'quantity': quantity,
      'supplier': supplier,
      'entryDate': entryDate.toIso8601String(),
      'notes': notes,
    };
  }
} 